/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package generalArchitecture.impl;

import generalArchitecture.ComputeBox;
import generalArchitecture.GeneralArchitecturePackage;

import generalArchitecture.Root;
import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Compute Box</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link generalArchitecture.impl.ComputeBoxImpl#getPrevious <em>Previous</em>}</li>
 *   <li>{@link generalArchitecture.impl.ComputeBoxImpl#getNext <em>Next</em>}</li>
 *   <li>{@link generalArchitecture.impl.ComputeBoxImpl#getRoot <em>Root</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class ComputeBoxImpl extends EObjectImpl implements ComputeBox {
	/**
	 * The cached value of the '{@link #getPrevious() <em>Previous</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPrevious()
	 * @generated
	 * @ordered
	 */
	protected EList<ComputeBox> previous;

	/**
	 * The cached value of the '{@link #getNext() <em>Next</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNext()
	 * @generated
	 * @ordered
	 */
	protected EList<ComputeBox> next;

	/**
	 * The cached value of the '{@link #getRoot() <em>Root</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRoot()
	 * @generated
	 * @ordered
	 */
	protected Root root;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComputeBoxImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return GeneralArchitecturePackage.Literals.COMPUTE_BOX;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ComputeBox> getPrevious() {
		if (previous == null) {
			previous = new EObjectWithInverseResolvingEList.ManyInverse<ComputeBox>(ComputeBox.class, this, GeneralArchitecturePackage.COMPUTE_BOX__PREVIOUS, GeneralArchitecturePackage.COMPUTE_BOX__NEXT);
		}
		return previous;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ComputeBox> getNext() {
		if (next == null) {
			next = new EObjectWithInverseResolvingEList.ManyInverse<ComputeBox>(ComputeBox.class, this, GeneralArchitecturePackage.COMPUTE_BOX__NEXT, GeneralArchitecturePackage.COMPUTE_BOX__PREVIOUS);
		}
		return next;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Root getRoot() {
		if (root != null && root.eIsProxy()) {
			InternalEObject oldRoot = (InternalEObject)root;
			root = (Root)eResolveProxy(oldRoot);
			if (root != oldRoot) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, GeneralArchitecturePackage.COMPUTE_BOX__ROOT, oldRoot, root));
			}
		}
		return root;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Root basicGetRoot() {
		return root;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRoot(Root newRoot) {
		Root oldRoot = root;
		root = newRoot;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, GeneralArchitecturePackage.COMPUTE_BOX__ROOT, oldRoot, root));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case GeneralArchitecturePackage.COMPUTE_BOX__PREVIOUS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getPrevious()).basicAdd(otherEnd, msgs);
			case GeneralArchitecturePackage.COMPUTE_BOX__NEXT:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getNext()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case GeneralArchitecturePackage.COMPUTE_BOX__PREVIOUS:
				return ((InternalEList<?>)getPrevious()).basicRemove(otherEnd, msgs);
			case GeneralArchitecturePackage.COMPUTE_BOX__NEXT:
				return ((InternalEList<?>)getNext()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case GeneralArchitecturePackage.COMPUTE_BOX__PREVIOUS:
				return getPrevious();
			case GeneralArchitecturePackage.COMPUTE_BOX__NEXT:
				return getNext();
			case GeneralArchitecturePackage.COMPUTE_BOX__ROOT:
				if (resolve) return getRoot();
				return basicGetRoot();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case GeneralArchitecturePackage.COMPUTE_BOX__PREVIOUS:
				getPrevious().clear();
				getPrevious().addAll((Collection<? extends ComputeBox>)newValue);
				return;
			case GeneralArchitecturePackage.COMPUTE_BOX__NEXT:
				getNext().clear();
				getNext().addAll((Collection<? extends ComputeBox>)newValue);
				return;
			case GeneralArchitecturePackage.COMPUTE_BOX__ROOT:
				setRoot((Root)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case GeneralArchitecturePackage.COMPUTE_BOX__PREVIOUS:
				getPrevious().clear();
				return;
			case GeneralArchitecturePackage.COMPUTE_BOX__NEXT:
				getNext().clear();
				return;
			case GeneralArchitecturePackage.COMPUTE_BOX__ROOT:
				setRoot((Root)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case GeneralArchitecturePackage.COMPUTE_BOX__PREVIOUS:
				return previous != null && !previous.isEmpty();
			case GeneralArchitecturePackage.COMPUTE_BOX__NEXT:
				return next != null && !next.isEmpty();
			case GeneralArchitecturePackage.COMPUTE_BOX__ROOT:
				return root != null;
		}
		return super.eIsSet(featureID);
	}

} //ComputeBoxImpl
